<h1><%= _('Listing groups') %></h1>

<%= link_to _('New group'), new_group_path %>

<br />
<hr />

<h2><%= _('Search') %></h2>
<%- form_tag({:action => 'index'}, :method => 'get') do -%>
	<%= text_field_tag 'q', nil %>
	<%= submit_tag _('Search') %>
<%- end -%>

<hr />

<table width="100%">
  <tr>
    <th colspan="0"><%= _('Name') %></th>
    <!--th><%= _('Description') %></th>
    <th><%= _('Prefrence') %></th-->
    <!--th>Created at</th>
    <th>Updated at</th-->
  </tr>
  <tr>
    <th colspan="0">(<%= _('Prefrence') %>) <%= _('Description') %></th>
  </tr>

<% @groups.each_with_index do |group, i| %>
  <tr class="record <%= 'even-record' if i % 2 == 0 %>">
    <td><%=h group.name %></td>
    <!--td><%=h group.description %></td>
    <td><%=h group.preference %></td-->
    <!--td><%=h group.created_at %></td>
    <td><%=h group.updated_at %></td-->
    <td><%= link_to _('Show'), group %></td>
    <td><%= link_to _('Edit'), edit_group_path(group) %></td>
    <td><%= link_to _('Destroy'), group, :confirm => _('Are you sure?'), :method => :delete %></td>
  </tr>
  <tr class="record <%= 'even-record' if i % 2 == 0 %>">
    <td colspan="0">(<%=h group.preference %>) <%=h group.description %></td>
  </tr>
  <tr class="record <%= 'even-record' if i % 2 == 0 %>">
    <td colspan="0"><div class="group">
      <%= link_to_function 'Hide items', "Effect.SlideUp($('items_#{group.id}'))", :id => "items_hide_#{group.id}", :style => "display: none" %><%= content_tag :div, (link_to_remote "#{group.items.size.to_s} items in this group", :update => "items_#{group.id}", :url => group_items_path(group), :method => 'get', :success => "$('items_hide_#{group.id}').show()"), :id => "items_#{group.id}", :class => "items" %>
    </div></td>
  </tr>
<% end %>
</table>
